cmake_minimum_required(VERSION 3.15)

project(wxWidgetDemo)

set(TOP_DIR ${CMAKE_CURRENT_LIST_DIR})
set(THIRDPARTY_DIR ${TOP_DIR}/thirdparty)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(THIRDPARTY_USE_WXWIDGET ON)
set(THIRDPARTY_USE_PORTAUDIO ON)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    # GCC 特定标志
    set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall -Werror -fno-omit-frame-pointer -mwindows")
    set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -Wall -mwindows")
    set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -Wall -mwindows")
    set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG -Wall -mwindows")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
    # MSVC 特定标志
    set(CMAKE_CXX_FLAGS_DEBUG "/MTd /Zi /Od /RTC1")
    set(CMAKE_CXX_FLAGS_RELEASE "/MT /Ox /DNDEBUG")
    set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /O2 /Zi /DNDEBUG")
    set(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O1 /DNDEBUG")
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/Debug")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Release")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/RelWithDebInfo")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}/MinSizeRel")

if(WIN32)
# Windows 平台的代码
    if(MSVC)
        set(CMAKE_CXX_STANDARD_REQUIRED ON)
        add_definitions(-DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS)
        add_compile_options("/utf-8")
            endif(MSVC)
elseif (APPLE)
# macOS 平台的代码
elseif (UNIX)
# Linux 平台的代码
elseif (MINGW)
# MinGW 平台的代码
else()
    message(DEPRECATION "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    message(FATAL_ERROR "Unknown platform")
    message(DEPRECATION "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
endif()

add_subdirectory(${THIRDPARTY_DIR})
add_subdirectory(./src)

add_executable(${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME} PRIVATE app)
target_link_libraries(app PRIVATE portaudio wx::core wx::base wx::aui)

if(MSVC)
    # 编译窗口程序，而不是控制台程序
    set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE)
endif()